package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.entity.ApplyInfoEntity;
import com.project.entity.BiddEntity;
import com.project.entity.PromotionEntity;
import com.project.entity.TenderEntity;
import com.project.service.IBiddService;
import com.project.service.IPromotionService;
import com.project.service.ITenderService;
import com.project.vo.AddConfirmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 供应商投标审核
 */
@RestController
@RequestMapping("tender")
public class TenderController {

    @Autowired
    private IBiddService biddService;
    @Autowired
    private ITenderService tenderService;

    /**
     *查找所有招标书  status  0，未发布招标，1，已发布招标，2，完成招标
     */
    @RequestMapping("findByItem")
    public IPage<BiddEntity> findByItem(Integer pageNO, int pageSize , int status) {
        return biddService.findByItem(pageNO,pageSize, status);
    }

    /**
     *查找招标书详情和对应的所有投标
     */
    @RequestMapping("findByRef")
    public BiddEntity findById(String biddRef) {
        BiddEntity byId = biddService.findById(biddRef);
        List<TenderEntity> tenderList = tenderService.findByBiddRef(biddRef);//查询所有投标记录
        byId.setTenderEntityList(tenderList);
        return byId;
    }

    /**
     *点击确认中标修改标书状态和生成中标确认表
     */
    @RequestMapping("confirmTender")
    public String confirmTender(@RequestBody AddConfirmVo confirmVo) {
        tenderService.confirmTender(confirmVo.getTenderRef(),confirmVo.getGoodsList());
        return "ok";
    }

@RequestMapping("findGoods")
    public List<ApplyInfoEntity> findGoods(String biddRef){
      return   tenderService.findGoods(biddRef);
    }


}
